# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/21 下午3:58
 @Author  : tgy
 
"""
import sys
import os
import flask_demo


class Flush:

    def __call__(self, *args, **kwargs):
        ...


class MyOut:
    ...
    __slots__ = ['_path', 'flush']

    def __init__(self, path):
        self.flush = Flush()
        self._path = path

    def write(self, obj):
        ...
        conten = obj
        print(conten)
        if self._path:
            with open(self._path, mode='at', encoding='utf-8') as f:
                f.write(obj)


def test():
    ...
    # sys.stdout = Declare()
    # sys.stdout = open('./log.txt',mode='at',encoding='utf-8')
    print('abc', file=MyOut('./log.txt'))


def test02():
    # 返回第一个bool(val) 为 True的val，如果都为False，则返回最后一个
    a = '' or '2'
    print(a)
    # 返回第一个bool(val) 为False的val, 如果都为True，则返回最后一个
    b = '1' and '2' and 333
    print(b)


def test03(n):
    ...
    m = n;
    while n:
        in_text = input('请输入:')
        if not in_text.isdigit():
            print('请输入数')
            continue
        if int(in_text) > 4:
            break
        n -= 1
    else:
        ...
        print(f'{m}次机会使用完成')


def test04():
    nums = [x for x in range(5, 10)]
    for i, num in enumerate(nums):
        print(i, num)


def outer(func):
    def inner(*args,**kwargs):
        return func(*args,**kwargs)
    return inner

def requestMapping(path,method='GET'):
    def outer(func):
        def inner(*args, **kwargs):
            return func(*args, **kwargs)
        return inner
    return outer





@outer # test05 = outer(test05)
def test05(name):
    ...
    print(name)

# method = requestMapping(path='/index')
# login = method(login)
# requestMapping(path='/index')(login)
@requestMapping(path='/index')
def login(username,password):
    ...
    print(username,password)



if __name__ == '__main__':
    ...
    # test03(2)
    # test05('tony')
    login('zhangsan','123456')